package Main;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import Actor.Actor;
import Actor.IfaceCharAction;
import Map.Floor;
import Map.Tile;
import View.ViewManager;

public class MyKeyListener implements KeyListener {
	private Actor charactor;
	private Floor map;
	ViewManager manager;
	public MyKeyListener(Actor _charactor, Floor _map,ViewManager _manager) {
		charactor = _charactor;
		map = _map;
		manager=_manager;
	}

	@Override
	public void keyTyped(KeyEvent e) {
	}

	@Override
	public void keyPressed(KeyEvent e) {
		IfaceCharAction command = null;
		switch (e.getKeyCode()) {
		case KeyEvent.VK_W:
			command = charactor.new UpLeftCommand();
			break;
		case KeyEvent.VK_S:
			command = charactor.new DownRightCommand();
			break;
		case KeyEvent.VK_A:
			command = charactor.new DownLeftCommand();
			break;
		case KeyEvent.VK_D:
			command = charactor.new UpRightCommand();
			break;
		}
		if (command != null) {
			command.doAcion(map,manager);
		}
//		IfaceCharAction command = null;
//		switch (e.getKeyCode()) {
//		case KeyEvent.VK_W:
//			command = charactor.new UpCommand();
//			break;
//		case KeyEvent.VK_S:
//			command = charactor.new DownCommand();
//			break;
//		case KeyEvent.VK_A:
//			command = charactor.new LeftCommand();
//			break;
//		case KeyEvent.VK_D:
//			command = charactor.new RightCommand();
//			break;
//		}
//		if (command != null) {
//			command.doAcion(map);
//		}
	}

	@Override
	public void keyReleased(KeyEvent e) {

	}

}
